package com.lmind.gps;

import java.net.InetSocketAddress;

import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.Log4jConfigurer;

import com.lmind.core.gps.alone.VirtualSmartphone;
import com.lmind.core.gps.gateway.SmartphoneGateway;
import com.lmind.core.gps.publish.GpsPub;
import com.lmind.core.publish.SocketPublisherRouter;

public class TmStarter {
	
	public static void main(String[] args) {
		
		try {
			Log4jConfigurer.initLogging("classpath:override/log4j.xml");
			ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

			SmartphoneGateway gateway = (SmartphoneGateway)context.getBean("gateway");
			gateway.bind(new InetSocketAddress(15110));
			
			VirtualSmartphone vt = (VirtualSmartphone)context.getBean("virtualTerminal");
			vt.connect(new InetSocketAddress("127.0.0.1", 15110));

			SocketPublisherRouter<GpsPub> gp = (SocketPublisherRouter<GpsPub>)context.getBean("socketPublisher");
			gp.bind(new NioSocketAcceptor(), new InetSocketAddress(15111));
			
			Thread.sleep(1000000);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
